﻿#ifndef QMLENGINE_H
#define QMLENGINE_H

#include <QObject>
#include <QQmlApplicationEngine>
#include <QQmlContext>

#include "connectmanager.h"
// #include "modbuscontrol.h"
// #include "printercontrol.h"
// #include "scannercontrol.h"
#include "processdatamanager.h"
#include "parameteritem.h"
#include "parametermodel.h"
#include "parametersqldb.h"


class QmlEngine : public QQmlApplicationEngine
{
    Q_OBJECT
public:
    QmlEngine(QObject *parent = nullptr);

    // 初始化数据库
    void initData();

    // 注册到QML
    void registerType();

    // 删除数据
    Q_INVOKABLE void qmlDeleteDataByIndex(int index);

    // 添加数据
    Q_INVOKABLE void qmlAddData();

    // 上载当前位置信息
    Q_INVOKABLE void updateCurrentLocation(QString knifeCrrt, QString rollerCrrt,
                                           QString stress01Crrt, QString stress02Crrt, QString stress03Crrt,
                                           QString f_knife01Crrt, QString f_knife02Crrt, QString f_knife03Crrt,
                                           QString b_knife01Crrt, QString b_knife02Crrt, QString b_knife03Crrt);

    // 保存数据
    Q_INVOKABLE void qmlSaveData(int index, QString key, QString value);

    // 搜索数据
    Q_INVOKABLE void qmlSearchData(QString find);

    // 刷新数据
    Q_INVOKABLE void qmlRefreshModelData();
signals:

    void getAllModel_Signal(ParameterModel* ItemModel);

public slots:

    void getAllModel_Slots(ParameterModel* ItemModel);

private:

    ProcessDataManager* m_dataManager = new ProcessDataManager(this);

    ParameterModel* m_ItemModel = new ParameterModel(this);

    ConnectManager* m_Connect = new ConnectManager(this);

};

#endif // QMLENGINE_H
